<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    class Company_finance_model extends MY_Model
    {
        public function __construct() 
        {
            parent::__construct();
            $this->tbl_name = 'companyfinance_infos';
        }
                
        
        function getStockTable($start = false, $limit = FALSE)
        {
            if( !$start )
            {
                $start = 0;
            }
            
            if( !$limit )
            {
                $limit = 20;
            }
            
            $sql = "
                    SELECT `companies`.`shortname`,`companyfinance_infos`.*
                    FROM `companyfinance_infos`, `companies`
                    WHERE `companyfinance_infos`.`company_id` = `companies`.`id`
                    AND  `companies`.`active` = 1
                    GROUP BY `companyfinance_infos`.`company_id`
                    LIMIT $start, $limit
                ";
            
            $query = $this->db->query($sql);
            
            return $query->result_array();
        }
        
        public function getCompanyFinanceBasic($companies_id)
        {                   
            $sql = "SELECT *
                    FROM finance_infos
                    WHERE active =1
                    AND companies_id = $companies_id
                    ORDER BY id ASC";
            
            $query = $this->db->query($sql);

            $data = array();
            if ($query->num_rows() > 0)
            {
               foreach ($query->result_array() as $row)
               {
                    $data[] = $row;    
               }
               return $data;;
            }                                                      
            
            return false;
        }
    }
?>
